﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
using System.Web.Security;

namespace Shsc.Net.FrameWork.Common.Util
{
    /// <summary>
    /// 
    /// </summary>
    public class CryptographyUtil
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="password"></param>
        /// <returns></returns>
        public static string SHACryptography(string password)
        {
            return Cryptography(password, "SHA");
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="password"></param>
        /// <returns></returns>
        public static string MD5Cryptography(string password)
        {
            return Cryptography(password, "MD5");
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="password"></param>
        /// <param name="passwordFormat"></param>
        /// <returns></returns>
        public static string Cryptography(string password, string passwordFormat)
        {
            if (String.IsNullOrEmpty(password))
            {
                return string.Empty;
            } else {
                return FormsAuthentication.HashPasswordForStoringInConfigFile(password, passwordFormat);
            }
        }
    }
}
